package com.kamistoat.meimeistore.modulessystem.service.impl;

import com.kamistoat.meimeistore.commoncore.utils.page.Query;
import com.kamistoat.meimeistore.modulessystem.dao.SysRoleMenuDao;
import com.kamistoat.meimeistore.modulessystem.service.SysRoleMenuService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kamistoat.meimeistore.commoncore.utils.page.PageUtils;
import com.kamistoat.meimeistore.apisystem.entity.SysRoleMenuEntity;


@Service("sysRoleMenuService")
public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuDao, SysRoleMenuEntity> implements SysRoleMenuService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<SysRoleMenuEntity> page = this.page(
                new Query<SysRoleMenuEntity>().getPage(params),
                new QueryWrapper<SysRoleMenuEntity>()
        );

        return new PageUtils(page);
    }

    /**
     * 删除 roleIds 的菜单权限关联
     */
    @Override
    public boolean deleteByRoleId(List<Long> roleIds) {
        return this.remove(new QueryWrapper<SysRoleMenuEntity>().in("role_id", roleIds));
    }

}